<html>
<head>
<title>Select User Account</title>
</head>
<body style="background: #FFFFFF;">
<script language="javascript">
function getUser ( idnumber, ffield, spanname, username )
{
	parent.SetId( idnumber, ffield, spanname, username ) ;
}
</SCRIPT>

<!---setup some variables for pagination--->
<cfparam name = "start" default="1">
<cfparam name = "disp" default="50">
<cfparam name = "end" default="999">
<cfparam name = "sortby" default = "joindate">
<cfparam name = "sortorder" default = "DESC">
<cfparam name = "updateid" default = "0">
<cfparam name = "viewgroup" default = "0">
<cfparam name = "searchbox" default = "">
<cfparam name = "viewtype" default = "0">
<cfparam name = "fname" default="none">
<cfparam name = "ffield" default="parentid">
<cfparam name = "spanname" default="parentname">

<cfinvoke component="cfcs.account" method="getusers" searchbox="#searchbox#" sortorder="#sortorder#" sortby="#sortby#" viewtype="#viewtype#" returnvariable="qusers" />
<cfinvoke component="cfcs.account" method="getusercount" searchbox="#searchbox#" viewtype="#viewtype#" returnvariable="totalrecords" />
	
<table width="100%" border="0" cellspacing="0" cellpadding="4">
  
  <tr>
    <td width="25%" valign="top">
	<cfoutput>
	<form name="Displayoptions" method="POST" Action="selectuser.cfm">
		<select name = "disp" onChange="this.form.submit();">
			<option value="8" <cfif disp IS '8'>SELECTED</cfif>>Display 8</option>
			<option value="15" <cfif disp IS '15'>SELECTED</cfif>>Display 15</option>
			<option value="25" <cfif disp IS '25'>SELECTED</cfif>>Display 25</option>
			<option value="50" <cfif disp IS '50'>SELECTED</cfif>>Display 50</option>
			<option value="100" <cfif disp IS '100'>SELECTED</cfif>>Display 100</option>
			<option value="999999" <cfif disp IS '999999'>SELECTED</cfif>>Display All</option>
		</select>
        <input type = "hidden" name = "ffield" value="#ffield#">
        <input type = "hidden" name = "fname" value="#fname#">
        <input type = "hidden" name = "searchbox" value="#searchbox#">
		<input type = "hidden" name = "viewtype" value="#viewtype#">
	</form>
    </cfoutput>
    </td>
    <td valign="top"><cfif disp LT totalrecords + 1>
	<div align="center"> <cfoutput> 
          <!---Display the page numbers--->
            <form name = "PageSelect" method="Post" Action="selectuser.cfm">
              <select name="start" OnChange="this.form.submit();">
                <cfset PageCount = 1>
                <cfloop Index="Pages" FROM="1" TO="#totalrecords#" Step="#disp#">
                  <option value = "#Pages#" <cfif Pages IS Start>SELECTED</cfif>>Page #PageCount#</option>
                  <cfset PageCount = PageCount + 1>
                </cfloop>
              </select>
				<input type = "hidden" value = "#disp#" name="disp">
				<input type = "hidden" name = "searchbox" value="#searchbox#">
				<input type = "hidden" name = "viewtype" value="#viewtype#">
                <input type = "hidden" name = "ffield" value="#ffield#">
                <input type = "hidden" name = "fname" value="#fname#">
            </form>
        </cfoutput></div>
	  </cfif>    </td>
	<td width="35%" valign="top" with="25%"></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">
		<form id="sorting" name="sorting" method="post" action="selectuser.cfm">
        Sorty By: 
      <select name="sortby" onChange="this.form.submit();">
        <option value="lastname" <cfif sortby IS 'lastname'>SELECTED</cfif>>Last Name</option>
        <option value="firstname" <cfif sortby IS 'firstname'>SELECTED</cfif>>First Name</option>
        <option value="email" <cfif sortby IS 'email'>SELECTED</cfif>>Email Address</option>
        <option value="city" <cfif sortby IS 'city'>SELECTED</cfif>>City</option>
        <option value="state" <cfif sortby IS 'state'>SELECTED</cfif>>State</option>
        <option value="sales" <cfif sortby IS 'sales'>SELECTED</cfif>>Number of Sales</option>
		<option value="aid" <cfif sortby IS 'affiliateid'>SELECTED</cfif>>Affiliate ID</option>
        </select>
      <select name="sortorder" onChange="this.form.submit();">
        <option value="ASC" <cfif sortorder IS 'ASC'>SELECTED</cfif>>Ascending</option>
        <option value="DESC" <cfif sortorder IS 'DESC'>SELECTED</cfif>>Descending</option>
      </select>
			<cfoutput>
			<input type = "hidden" name = "ffield" value="#ffield#">
			<input type = "hidden" name = "fname" value="#fname#">
            <input type = "hidden" name = "start" value="#start#">
			<input type = "hidden" name = "disp" value="#disp#">
			<input type = "hidden" name = "viewtype" value="#viewtype#">
			<input type = "hidden" name = "searchbox" value="#searchbox#">
			</cfoutput>
      </form>    </td>
    <td align="left" valign="top">
		<form id="form1" name="form1" method="post" action="selectuser.cfm">
		Search: <cfoutput><input name="searchbox" type="text" id="searchbox" size="20" value="#searchbox#" /></cfoutput> <input type="submit" name="Submit" id="abutton" value="Submit" />
		<cfoutput><input type = "hidden" name = "display" value="#disp#">
        <input type = "hidden" name = "ffield" value="#ffield#">
        <input type = "hidden" name = "fname" value="#fname#">		
		</cfoutput>
		</form></td>
  </tr>
</table>
<!---Header row--->
<table width="100%" border="0" cellspacing="0" cellpadding="6">
  <tr>
    <td width="25%"id="columnheaders">Name</td>
    <td width="25%"id="columnheaders">Email Address</td>
    <td width="15%" align="left"id="columnheaders">City</td>
    <td width="10%" align="left"id="columnheaders">State</td>
    <td width="10%"id="columnheaders">AccountID</td>
    <td width="15%"id="columnheaders"></td>
  </tr>
<!---begin listing them--->
<form name = "mbrTable" <cfoutput>action="index.cfm?c=affiliates&a=delete"</cfoutput> method="post">
<cfloop query = "qusers">
  <tr class="menu_row" onMouseDown="this.className = 'menu_row_over';" onmouseover = "this.className = 'menu_row_over2';" onMouseUp="this.className = 'menu_row_over';" onmouseout = "this.className = 'menu_row';">
    <td nowrap="nowrap"><cfoutput>#firstname# #lastname#</cfoutput></td>
    <td nowrap="nowrap"><cfoutput>#email#</cfoutput></td>
    <td nowrap="nowrap"><cfoutput>#city#</cfoutput></td>
    <td nowrap="nowrap"><cfoutput>#state#</cfoutput></td>
    <td><cfoutput>#aid#</cfoutput></td>
    <td><cfoutput>
        <div align="center">
        <a href="##" onClick="getUser('#aid#','#ffield#','#spanname#','#firstname# #lastname#')">Select</a>
		</div>
		</cfoutput>
      </td>
  </tr>
</cfloop>
</form>
</table>
<cfif totalrecords IS 0>
	<cfquery name="qtype" datasource="#request.dsn#">
    SELECT * FROM core_accounttypes
    WHERE id = <cfqueryparam value="#viewtype#" cfsqltype="cf_sql_integer">
    </cfquery>
    
	You have no <cfoutput>#qtype.tname#</cfoutput><cfif right(qtype.tname, 1) IS 's'>'<cfelse>'s</cfif>
</cfif>
</body>
</html>